<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="/global/jsp-header.jsp"%>
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html">
		<title>访问路径列表</title>
		<%@ include file="/global/tablesort-header.jsp"%>
		<script>
		var rs = "${allActionUri.size()}";
		rs = ((!rs)? 0 : parseInt(rs))+1;
		var h = rs * 27 + 50;
		$(window.parent.document).find("#queryResult").removeClass("hide");
		$(window.parent.document).find("#actionUriResultIframe").height(h+100);
		$(window.parent.parent.document).find("#actionUriIframe").height(h+440);
		
		$(document).ready(function(){
			window.parent.updateTitle("${menu.menuName}");
			$(':radio').attr('disabled', true);
			$(':checkbox:checked').each(function(){
				$(this).parent().siblings().find(':radio').removeAttr('disabled');
			});

			$(':checkbox[name=actionIds]').click(function(){
				if($(this).attr('checked')) {
					$(this).parent().siblings().find(':radio').removeAttr('disabled');
				} else {
					$(this).parent().siblings().find(':radio').attr('disabled', true);
				}
			});
		});
		</script>
	</head>
	<body>
		<c:if test="${allActionUri.size() > 0}">
			<table id="myTable" cellspacing="1" class="tablesorter">
				<thead>
					<tr>
						<th>
							操作编号
						</th>
						<th>
							操作名
						</th>
						<th>
							注释
						</th>
						<th>
					    	是否默认
					    </th>
					</tr>
				</thead>
				<tbody>
					<form action="/rbac/edit-menu-with-action.do" name="myform" id="myform"  method="post">
						<input type="hidden" name="menu.menuId" value="${menu.menuId }">
						<c:forEach items="${allActionUri }" var="item">
							<tr actionId=${item.actionId }>
								<c:set value="${false}" var="aomChecked"></c:set>
					 			<c:set value="${0}" var="isDefault"></c:set>
					 			<c:forEach items="${dataList}" var="aom">
					 				<c:if test="${!aomChecked && item.actionId eq aom.actionId}">
					 					<c:set value="${true}" var="aomChecked"></c:set>
					 					<c:set value="${aom.isDefault}" var="isDefault"></c:set>
					 				</c:if>
					 			</c:forEach>
								<td>
 									<label for="a_${item.actionId }">${item.actionId }</label>
									<input type="checkbox" name="actionIds" value="${item.actionId }" ${aomChecked ? 'checked="checked"' : '' }/>
								</td>
								<td>
									${item.actionName }
								</td>
								<td>
									${item.note }
								</td>
								<td>
									<label for="df_${item.actionId }_1">有</label>
									<input type="radio" name="isDefault_${item.actionId }" value="1"  ${isDefault eq 1 ? 'checked="checked"' : '' }/>
 									<label for="df_${item.actionId }_2">无</label>
 									<input type="radio" name="isDefault_${item.actionId }" value="0"  ${isDefault eq 0 ? 'checked="checked"' : '' }/>
								</td>
							</tr>
						</c:forEach>
						<input type="submit" value="提交" class="button blue"/>
					</form>
				</tbody>
			</table>
		</c:if>
		<c:if test="${allActionUri.size() <= 0}">
			<div class="emptyResult">
				抱歉，没有找到相关操作路径。
			</div>
		</c:if>
	</body>
</html>
